Skip to content

fix(solid-query): subscribe to new observer when queryClient accessor switches#11111

Open
rohanpatel2002 wants to merge 1 commit into
TanStack:mainfrom
rohanpatel2002:fix/solid-query-client-switch-observer
Open

fix(solid-query): subscribe to new observer when queryClient accessor switches#11111
rohanpatel2002 wants to merge 1 commit into
TanStack:mainfrom
rohanpatel2002:fix/solid-query-client-switch-observer

Conversation

@rohanpatel2002

@rohanpatel2002 rohanpatel2002 commented Jul 23, 2026

Copy link
Copy Markdown

Changes

Fixes #11106.
When the queryClient accessor passed to useQuery / useBaseQuery switched, createClientSubscriber() ran before setObserver(newObserver), so the subscription re-attached to the old observer. Refetches landed in the previous client's cache and the new client's entry stayed pending/idle.

  • Reorder: setObserver(newObserver) then createClientSubscriber()
  • Tighten "should refetch query when queryClient changes" to assert queryClient2 cache state.data === 'data'
  • Patch changeset for @tanstack/solid-query

Checklist

  • Followed the Contributing guide
  • Tested locally (vitest for the client-switch case / solid-query suite)
  • Changeset included (published code)

Release Impact

  • Affects published code — changeset included

Summary by CodeRabbit

  • Bug Fixes
    • Fixed query updates not being observed after switching the active query client in Solid Query.

… switches

createClientSubscriber captured observer() before setObserver on client
change, so the subscription stayed on the old observer and stranded the
new client's cache. Set the observer first, then subscribe. Tighten the
existing client-switch test to assert cached data. Fixes TanStack#11106
Copilot AI review requested due to automatic review settings July 23, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98fece8f-cebe-426d-b84c-dd9edb38d1eb

📥 Commits

Reviewing files that changed from the base of the PR and between 86bb8a6 and e75e65a.

📒 Files selected for processing (1)
  • .changeset/solid-client-switch-observer.md

📝 Walkthrough

Walkthrough

Adds a patch changeset for @tanstack/solid-query, documenting that switching the queryClient accessor subscribes to the new observer.

Changes

Solid QueryClient switching

Layer / File(s) Summary
Patch changeset
.changeset/solid-client-switch-observer.md
Declares a patch release for @tanstack/solid-query and documents subscription to the new observer when the queryClient accessor changes.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • TanStack/query#11105: Updates tests that exercise queryClient switching and observer resubscription.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The summarized changes only add a changeset, so the bug fix and regression assertion required by #11106 are not present. Implement the observer reorder in useBaseQuery, add the client2 cache assertion, and keep the changeset aligned with the shipped fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the solid-query observer-switch bug fix and matches the described change.
Description check ✅ Passed The description follows the template with Changes, Checklist, and Release Impact sections filled in.
Out of Scope Changes check ✅ Passed The only shown change is an in-scope changeset for the described fix, with no unrelated edits visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)

2 participants